<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>领取用户列表</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <link rel="stylesheet" href="${ctx}/css/ui/activity/member_act_list.css">
    <%@include file="../include/commonFile.jsp" %>
    <style>
        .option {
            text-align: left !important;
        }
    </style>
</head>
<body>
<!--头部-->
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <input type="hidden" id="returnUrl" value="<c:if test="${empty giftOrder.targetId}">${ctx}/gift/gift/list.do</c:if>
<c:if test="${not empty giftOrder.targetId}">${ctx}/gift/gift/giftTargetList.do?giftId=${giftOrder.giftId}</c:if>"/>

            <form class="layui-form" action="${ctx}/gift/gift/giftOrderList.do?giftId=${gift.id}&targetId=${giftOrder.targetId}" id="myForm" method="post">
                <input type="hidden" name="pageNo" id="pageNo"/>
                <div class="f-search-bar">
                    <div class="search-container">
                        <ul class="search-form-content">
                            <li class="form-item-inline"><label class="search-form-lable">领取用户</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="memberName" class="layui-input" value="${input.memberName}">
                                </div>
                            </li>

                            <li class="form-item"><label class="search-form-lable">领取时间</label>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createStart" value="${input.createStart}" placeholder="开始日">
                                    </div>
                                    -
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createEnd" value="${input.createEnd}" placeholder="截止日">
                                    </div>
                                </div>
                            </li>

                            <li class="form-item-inline">
                                <div class="sub-btns">
                                    <a class="layui-btn layui-btn-danger submitBtn" href="javascript:submitFunction('#myForm')">查询</a>
                                    <a class="layui-btn layui-btn-normal" href="javascript:resetFunction('#myForm')">重置</a>
                                </div>
                            </li>
                        </ul>
                        <%--<ul class="search-form-content">
                            <li class="form-item"><label class="search-form-lable">应用场景</label>
                                <div class="check-btn-inner" id="type">
                                    <a href="javascript:void(0);" onclick="setTimeType($(this), null,'#myForm')" ${empty giftOrder.type ? 'class="active"' : ''}>全部</a>
                                    <a href="javascript:void(0);" onclick="setTimeType($(this),'ZC_ACTIVITY','#myForm')" ${giftOrder.type == 'ZC_ACTIVITY' ? 'class="active"' : ''}>众筹</a>
                                    <a href="javascript:void(0);" onclick="setTimeType($(this),'ACTIVITY','#myForm')" ${giftOrder.type == 'ACTIVITY' ? 'class="active"' : ''}>活动</a>
                                    <a href="javascript:void(0);" onclick="setTimeType($(this),'ARTICLE','#myForm')" ${giftOrder.type == 'ARTICLE' ? 'class="active"' : ''}>文章</a>
                                    <a href="javascript:void(0);" onclick="setTimeType($(this),'GOODS','#myForm')" ${giftOrder.type == 'GOODS' ? 'class="active"' : ''}>玩法</a>
                                    <input type="hidden" name="type" value="${giftOrder.type}"/>
                                </div>
                            </li>
                        </ul>--%>
                    </div>
                </div>
            </form>

            <div class="list-content mt10">
                <%--<ul class="num">
                    <div class="r">
                        <li style="cursor: pointer;" class="r">
                            <a class="layui-btn layui-btn-danger layui-btn-sm" id="btnExport">导出EXCEL</a>
                        </li>
                    </div>
                    <p class="cl"></p>
                </ul>--%>
                <div class="cl">
                    <table class="layui-table" id="myTable">
                        <colgroup>
                            <col>
                            <col width="100px">
                            <col>
                            <col>
                            <col>
                            <c:if test="${gift.model == 1}">
                                <col>
                                <col width="100px">
                                <col width="100px">
                                <%--<col>--%>
                            </c:if>
                            <c:if test="${gift.model == 2}">
                                <col>
                                <col>
                            </c:if>
                            <col width="90px">
                        </colgroup>
                        <thead>
                        <tr>
                            <th>项目名称</th>
                            <th>应用场景</th>
                            <th>礼包单号</th>
                            <th>领取用户</th>
                            <th>领取时间</th>
                            <c:if test="${gift.model == 1}">
                                <th>票券名称</th>
                                <th>核销码</th>
                                <th>是否消费</th>
                                <%--<th>消费日期</th>--%>
                            </c:if>
                            <c:if test="${gift.model == 2}">
                                <th>物流状态</th>
                                <th>操作</th>
                            </c:if>
                            <th>查看信息</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach var="order" items="${orders}">
                            <tr class="info">
                                <td><div>${order.targetName}</div></td>
                                <td>
                                    <div>
                                        <c:choose>
                                            <c:when test="${order.type == 'ZC_ACTIVITY'}">众筹</c:when>
                                            <c:when test="${order.type == 'ACTIVITY'}">活动</c:when>
                                            <c:when test="${order.type == 'ARTICLE'}">文章</c:when>
                                            <c:when test="${order.type == 'GOODS'}">玩法</c:when>
                                        </c:choose>
                                    </div>
                                </td>
                                <td><div>${order.giftNum}</div></td>
                                <td class="table-member" onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${order.receiverId}','400px','470px')">
                                    <div class="member-cell">
                                        <div class="member-logo" style="background-image: <c:if test="${order.receiverLogo != null}">url('${order.receiverLogo}?imageMogr2/auto-orient/crop/126x126'),</c:if>url(${ctx}/image/def_user_logo.png)"></div>
                                        <div class="member-name ellipsis-1">
                                            <a class="blue" title="${order.receiverName}" href="javascript:void(0);">${order.receiverName}</a>
                                        </div>
                                    </div>
                                </td>
                                <td><div><fmt:formatDate value="${order.updateDate}" pattern="yyyy-MM-dd HH:mm"/></div></td>
                                <c:if test="${gift.model == 1}">
                                    <td><div>${order.couponName}</div></td>
                                    <td><div>${order.verifyCode}</div></td>
                                    <td>
                                        <div>
                                            <c:if test="${empty order.isSpending || order.isSpending == 2}">未消费</c:if>
                                            <c:if test="${order.isSpending == 1}">已消费</c:if>
                                        </div>
                                    </td>
                                    <%--<td>
                                        <div>
                                            <c:if test="${not empty order.spendingTime}">
                                                <fmt:formatDate value="${order.spendingTime}" pattern="yyyy-MM-dd HH:mm"/>
                                            </c:if>
                                        </div>
                                    </td>--%>
                                </c:if>
                                <c:if test="${gift.model == 2}">
                                    <td>
                                        <div>
                                            <c:if test="${order.status == -1}">已发货</c:if>
                                            <c:if test="${order.status == 0}">无轨迹</c:if>
                                            <c:if test="${order.status == 1}">已揽收</c:if>
                                            <c:if test="${order.status == 2}">在途中</c:if>
                                            <c:if test="${order.status == 201}">到达派件城市</c:if>
                                            <c:if test="${order.status == 3}">已签收</c:if>
                                            <c:if test="${order.status == 4}">问题件</c:if>
                                        </div>
                                    </td>
                                    <td class="opts-btns tb-opts">
                                        <div class="comm-opts">
                                            <c:if test="${order.model == 2 && empty order.status}">
                                                <a href="javascript:openDialog('填写发货信息-${order.receiverName}', '${ctx}/logistics/logistics/giftShipments.do?targetId=${order.id}', '390px', '300px');">发货</a>
                                            </c:if>
                                            <c:if test="${order.model == 2 && not empty order.status}">
                                                <c:if test="${order.status != 3}">
                                                    <a href="javascript:openDialog('修改发货信息-${order.receiverName}', '${ctx}/logistics/logistics/giftShipments.do?targetId=${order.id}', '390px', '300px');">修改发货信息</a>
                                                </c:if>
                                                <a href="javascript:openDialogShow('查看物流-${order.receiverName}', '${ctx}/logistics/logistics/findLogisticsById.do?logisticsId=${order.logisticsId}', '800px', '600px');">查看物流</a>
                                            </c:if>
                                        </div>
                                    </td>
                                </c:if>
                                <td>
                                    <div class="option">
                                        <i class="iconfont icon-unfold"></i>
                                        <i class="iconfont icon-fold dis-none"></i>
                                    </div>
                                </td>
                            </tr>
                            <tr class="dis-none info-detail">
                                <td <c:if test="${gift.model == 1}">colspan="9"</c:if> <c:if test="${gift.model == 2}">colspan="8"</c:if>>
                                    <div>
                                        <table width="100%" class="childTable layui-table" lay-skin="row" style="margin: 0px">
                                            <tbody>
                                            <tr>
                                                <td>收货人</td>
                                                <td>${order.consigneeName}</td>
                                            </tr>
                                            <tr>
                                                <td>联系电话</td>
                                                <td>${order.consigneePhone}</td>
                                            </tr>
                                            <tr>
                                                <td>详细地址</td>
                                                <td>${order.consigneeAddress}</td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </td>
                            </tr>
                        </c:forEach>
                        <c:if test="${page.totalCount == 0}">
                            <tr class="f16 tc mt15">
                                <c:if test="${gift.model == 1}">
                                    <td colspan="9">还没有领取数据</td>
                                </c:if>
                                <c:if test="${gift.model == 2}">
                                    <td colspan="8">还没有领取数据</td>
                                </c:if>
                            </tr>
                        </c:if>
                        </tbody>
                    </table>
                </div>
            </div>
            <div id="page_content" class="page-container"></div>
        </div><!--底部-->
        <%@include file="../include/footer.jsp" %>
    </section>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript">
    $(function () {
        layui.use(['laydate'], function () {
            var laydate = layui.laydate;

            // 查询发布日期
            var start = {
                elem: 'input[name=createStart]'
            };

            var end = {
                elem: 'input[name=createEnd]'
            };
            laydate.render(start);
            laydate.render(end);

            // 加载分页
            loadPageNew({
                elem: 'page_content',
                totalCount: '${page.totalCount}',
                limit: '${page.limit}',
                page: '${page.page}'
            });
        });


        $('#myTable').delegate('.option', 'click', function (e) {
            var info = $(this).closest('.info');
            if (!info.hasClass('active')) {//打开
                $('.info').removeClass('active');
                $(".info-detail").removeClass('dis-block');
                info.toggleClass('active');
                $(info).next(".info-detail").addClass('dis-block');
            } else {
                info.toggleClass('active');
                $(info).next(".info-detail").removeClass('dis-block');
            }
        });

        $("#btnExport").click(function () {
            layer.confirm('确认要导出Excel吗?', {
                icon: 3,
                title: '系统提示'
            }, function (index) {
                var url = "${ctx}/gift/gift/giftOrderExport.do?giftId=${gift.id}";
                //loading层
                var loadIndex = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
                $.post(url, $("#myForm").serialize(), function (res) {
                    top.layer.close(loadIndex);
                    if (res.success) {
                        window.location.href = res.data;
                    } else {
                        util.layerMsgError(res.description)
                    }
                });
                top.layer.close(index);
            });
        });
    })

    function openDialog(title, url, width, height, target) {
        layer.open({
            type : 2,
            area : [ width, height ],
            title : title,
            maxmin : true, //开启最大化最小化按钮
            content : url,
            btn : [ '确定', '关闭' ],
            yes : function(index, layero) {
                var body = layer.getChildFrame('body', index);
                var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                var inputForm = body.find('#inputForm');
                var top_iframe;
                if (target) {
                    top_iframe = target;//如果指定了iframe，则在改frame中跳转
                } else {
                    top_iframe = '_parent';//获取当前active的tab的iframe
                }
                inputForm.attr("target", top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示

                if (iframeWin.contentWindow.doSubmit()) {
                    setTimeout(function() {
                        top.layer.close(index);
                        location.reload();
                    }, 100);//延时0.1秒，对应360 7.1版本bug
                }
            },
            cancel : function(index) {
            }
        });
    }
</script>
<script type="text/javascript">
    txz.initHeader({
        nav:[{
            name: '礼包管理',
            href: $("#returnUrl").val()
        },{
            name: '${gift.name}',
            curr: true
        },{
            name: '领取用户列表',
            curr: true
        }],
        info:'<span class="f12">共<b id="totalCount">${page.totalCount}</b>条记录</span>',
        btns:[{
            type:'back'
        }]
    });
</script>
</body>
</html>